﻿// Copyright (c) 2014 Morten Bakkedal
// This code is published under the MIT License.

using System;
using System.Globalization;

namespace FuncLib.DualFunctions.Expressions
{
	internal class NumberExpression : Expression
	{
		private double value;

		public NumberExpression(double value)
		{
			this.value = value;
		}

		public override string GenerateCode()
		{
			string s = value.ToString("r", CultureInfo.InvariantCulture) + "d";
			
			if (value < 0.0)
			{
				s = "(" + s + ")";
			}

			return s;
		}

		public double Value
		{
			get
			{
				return value;
			}
		}
	}
}
